package com.bone.constant;

import java.util.Properties;


public class Constant {
	
	public final static String DEFAULT_LOCATION = "www";
	
	private static Properties properties;
	private static volatile Constant instance=null;
	
	public static final String LV_SESSION_ID="lvsessionid";
	
	public final static String SESSION_USER = "SESSION_USER";
	public final static String SESSION_USER_PERM_PERMISSION = "SESSION_USER_PERM_PERMISSION";

	
	/**
	 * .角色类型.
	 */
	public final static String MODULE_TYPE_MENU = "0";
	public final static String MODULE_TYPE_PAGE = "1";
	
	
	
	public static enum COMMON_STATUS {
		NORMAL("正常"),
		CANCEL("取消"),
		FINISH("完成");
		private String cnName;
		COMMON_STATUS(String name){
			this.cnName=name;
		}
		public String getCode(){
			return this.name();
		}
		public String getCnName(){
			return this.cnName;
		}
		public static String getCnName(String code){
			for(COMMON_STATUS item:COMMON_STATUS.values()){
				if(item.getCode().equals(code))
				{
					return item.getCnName();
				}
			}
			return code;
		}
		public String toString(){
			return this.name();
		}
	}
	
	public static enum  ACTIVATE_STATUS {
		NORMAL("启用"),
		CANCEL("停用");
		
		private String cnName;
		ACTIVATE_STATUS(String name){
			this.cnName=name;
		}
		public String getCode(){
			return this.name();
		}
		public String getCnName(){
			return this.cnName;
		}
		public static String getCnName(String code){
			for(ACTIVATE_STATUS item:ACTIVATE_STATUS.values()){
				if(item.getCode().equals(code))
				{
					return item.getCnName();
				}
			}
			return code;
		}
		public String toString(){
			return this.name();
		}
	}
	
	public static enum  COMM_TYPE {
		ONE("一级菜单"),
		TWO("二级菜单"),
		THREE("三级菜单"),
		BAGS("标签");
		private String cnName;
		COMM_TYPE(String name){
			this.cnName=name;
		}
		public String getCode(){
			return this.name();
		}
		public String getCnName(){
			return this.cnName;
		}
		public static String getCnName(String code){
			for(COMM_TYPE item:COMM_TYPE.values()){
				if(item.getCode().equals(code))
				{
					return item.getCnName();
				}
			}
			return code;
		}
		public String toString(){
			return this.name();
		}
	}
	
	
	public static enum  GATEWAY_TYPE {
		ONLINE("线上支付"),
		OTHER("其它支付"),
		DIST("分销或团购支付");
		
		private String cnName;
		GATEWAY_TYPE(String name){
			this.cnName=name;
		}
		public String getCode(){
			return this.name();
		}
		public String getCnName(){
			return this.cnName;
		}
		public static String getCnName(String code){
			for(GATEWAY_TYPE item:GATEWAY_TYPE.values()){
				if(item.getCode().equals(code))
				{
					return item.getCnName();
				}
			}
			return code;
		}
		public String toString(){
			return this.name();
		}
	}
	
	
	
	public static enum REFUNDMENT_STATUS {
		UNVERIFIED("未审核"),
		REFUND_VERIFIED("退款单审核通过"),
		REJECTED(" 不通过(拒绝,驳回)"),
		VERIFIED("审核通过(等待退款)"),
		REFUNDED("已退款"),
		REFUNDED_PART("部分退款"),
		CANCEL("退款单取消"),
		REFUNDED_TASK("退款处理中"),
		FAIL("退款失败");
		
		private String cnName;
		REFUNDMENT_STATUS(String name){
			this.cnName=name;
		}
		public String getCode(){
			return this.name();
		}
		public String getCnName(){
			return this.cnName;
		}
		public static String getCnName(String code){
			for(REFUNDMENT_STATUS item:REFUNDMENT_STATUS.values()){
				if(item.getCode().equals(code))
				{
					return item.getCnName();
				}
			}
			return code;
		}
		public String toString(){
			return "code:"+this.name()+",cnName:"+this.cnName;
		}
	}
	
	public static enum REFUNDMENT_TYPE {
		/** 补偿 */
		COMPENSATION("补偿"),
		/** 订单退款 */
		ORDER_REFUNDED("订单退款");
		
		private String cnName;
		REFUNDMENT_TYPE(String name){
			this.cnName=name;
		}
		public String getCode(){
			return this.name();
		}
		public String getCnName(){
			return this.cnName;
		}
		public static String getCnName(String code){
			for(REFUNDMENT_TYPE item:REFUNDMENT_TYPE.values()){
				if(item.getCode().equals(code))
				{
					return item.getCnName();
				}
			}
			return code;
		}
		public String toString(){
			return "code:"+this.name()+",cnName:"+this.cnName;
		}
	}
	
	
	public static enum USER_STATUS {
		NORMAL("正常"),
		FREEZE("冻结"),
		CANCEL("取消");
		
		private String cnName;
		USER_STATUS(String name){
			this.cnName=name;
		}
		public String getCode(){
			return this.name();
		}
		public String getCnName(){
			return this.cnName;
		}
		public static String getCnName(String code){
			for(USER_STATUS item:USER_STATUS.values()){
				if(item.getCode().equals(code))
				{
					return item.getCnName();
				}
			}
			return code;
		}
		public String toString(){
			return this.name();
		}
	}
	
	public static enum PAYMENT_BIZ_TYPE {
		ORDER("订单支付"),
		TRADE("内部交易"),
		USER_ACCOUNT("帐户充值"),
		MERGE_PAY("合并支付");
		private String cnName;
		PAYMENT_BIZ_TYPE(String name){
			this.cnName=name;
		}
		public String getCode(){
			return this.name();
		}
		public String getCnName(){
			return this.cnName;
		}
		public static String getCnName(String code){
			for(PAYMENT_BIZ_TYPE item:PAYMENT_BIZ_TYPE.values()){
				if(item.getCode().equals(code))
				{
					return item.getCnName();
				}
			}
			return code;
		}
		public String toString(){
			return this.name();
		}
	}
	
	public static enum PAYMNET_GATEWAY{
		ALIPAY("支付宝"),
		UNIONPAY("银联支付"),
		CMB("招商银行"),
		COMM("交通银行"),
		BOC("中国银行"),
		BYPAY("百付电话支付"),
		LAKALA("拉卡拉");
		private String cnName;
		PAYMNET_GATEWAY(String name){
			this.cnName=name;
		}
		public String getCode(){
			return this.name();
		}
		public String getCnName(){
			return this.cnName;
		}
		public static String getCnName(String code){
			for(PAYMNET_GATEWAY item:PAYMNET_GATEWAY.values()){
				if(item.getCode().equals(code))
				{
					return item.getCnName();
				}
			}
			return code;
		}
		public String toString(){
			return this.name();
		}
	}
	
	
	
	
	/**
	 * 订单支付对象.
	 * @author kevin
	 *
	 */
	public static enum ORDER_PAYMENT_TARGET {
		PLATFORM("平台"),
		SUPPLIER("供应商");
		private String cnName;
		ORDER_PAYMENT_TARGET(String name){
			this.cnName=name;
		}
		public String getCode(){
			return this.name();
		}
		public String getCnName(){
			return this.cnName;
		}
		public static String getCnName(String code){
			for(ORDER_PAYMENT_TARGET item:ORDER_PAYMENT_TARGET.values()){
				if(item.getCode().equals(code))
				{
					return item.getCnName();
				}
			}
			return code;
		}
		public String toString(){
			return this.name();
		}
	}
	
	public static enum ORDER_STATUS {
		NORMAL("正常"),
		CANCEL("取消");
		
		private String cnName;
		ORDER_STATUS(String name){
			this.cnName=name;
		}
		public String getCode(){
			return this.name();
		}
		public String getCnName(){
			return this.cnName;
		}
		public static String getCnName(String code){
			for(ORDER_STATUS item:ORDER_STATUS.values()){
				if(item.getCode().equals(code))
				{
					return item.getCnName();
				}
			}
			return code;
		}
		public String toString(){
			return this.name();
		}
	}
	/**
	 * 支付渠道.
	 * @author kevin
	 *
	 */
	public static enum ORDER_CHANNEL{
		FOREGROUND("前台"),
		BACKGROUND("后台");
		
		private String cnName;
		ORDER_CHANNEL(String name){
			this.cnName=name;
		}
		public String getCode(){
			return this.name();
		}
		public String getCnName(){
			return this.cnName;
		}
		public static String getCnName(String code){
			for(ORDER_CHANNEL item:ORDER_CHANNEL.values()){
				if(item.getCode().equals(code))
				{
					return item.getCnName();
				}
			}
			return code;
		}
		public String toString(){
			return this.name();
		}
	}
	
	/**
	 * 订单显示状态.
	 * @author kevin
	 *
	 */
	public static enum ORDER_VIEW_STATUS{
		NORMAL("正常"),
		UNPAY("未支付"),
		PARTPAY("部分支付"),
		PAYED("已支付"),
		FINISHED("完成"),
		CANCEL("取消");
		
		private String cnName;
		ORDER_VIEW_STATUS(String name){
			this.cnName=name;
		}
		public String getCode(){
			return this.name();
		}
		public String getCnName(){
			return this.cnName;
		}
		public static String getCnName(String code){
			for(ORDER_VIEW_STATUS item:ORDER_VIEW_STATUS.values()){
				if(item.getCode().equals(code))
				{
					return item.getCnName();
				}
			}
			return code;
		}
		public String toString(){
			return this.name();
		}
	}
	
	/**
	 * 订单支付状态.
	 * @author kevin
	 *
	 */
	public static enum ORDER_PAYMENT_STATUS{
		UNPAY("未支付"),
		PARTPAY("部分支付"),
		PAYED("已支付");
		private String cnName;
		ORDER_PAYMENT_STATUS(String name){
			this.cnName=name;
		}
		public String getCode(){
			return this.name();
		}
		public String getCnName(){
			return this.cnName;
		}
		public static String getCnName(String code){
			for(ORDER_PAYMENT_STATUS item:ORDER_PAYMENT_STATUS.values()){
				if(item.getCode().equals(code))
				{
					return item.getCnName();
				}
			}
			return code;
		}
		public String toString(){
			return this.name();
		}
	}
	
	public static enum ORDER_SERVICE_TYPE {
		COMPLAINT("投诉 "),
		NORMAL("常规售后");
		private String cnName;
		ORDER_SERVICE_TYPE(String name){
			this.cnName=name;
		}
		public String getCode(){
			return this.name();
		}
		public String getCnName(){
			return this.cnName;
		}
		public static String getCnName(String code){
			for(ORDER_SERVICE_TYPE item:ORDER_SERVICE_TYPE.values()){
				if(item.getCode().equals(code))
				{
					return item.getCnName();
				}
			}
			return code;
		}
		public String toString(){
			return this.name();
		}
	}
	
	/**送货方式**/
	public static enum DELIVERY_TYPE{
		/**快递**/
		EXPRESS("快递"),
		/**ems**/
		EMS("EMS"),
		/**自取**/
		SELF("自取");
		
		private String cnName;
		DELIVERY_TYPE(String name){
			this.cnName=name;
		}
		public String getCode(){
			return this.name();
		}
		public String getCnName(){
			return this.cnName;
		}
		public static String getCnName(String code){
			for(DELIVERY_TYPE item:DELIVERY_TYPE.values()){
				if(item.getCode().equals(code))
				{
					return item.getCnName();
				}
			}
			return code;
		}
		public String toString(){
			return "code:"+this.name()+",cnName:"+this.cnName;
		}
	}

	
	/**结算方式**/
	public static enum BUSINESS_CYCLE{
		ORDER_SETTLEMENT("订单结算"),
		DAY_SETTLEMENT("天结算"),
		WEEK_SETTLEMENT("星期结算"),
		HALE_MONTH_SETTLEMENT("半月结算"),
		MONTH_SETTLEMENT("月结算"),
		QUARTER_SETTLEMENT("季度结算"),
		HALE_YEAR_SETTLEMENT("半年结算"),
		YEAR_SETTLEMENT("年结算"),
		AGREEMENT_SETTLEMENT("约定结算");
		 
		
		private String cnName;
		BUSINESS_CYCLE(String name){
			this.cnName=name;
		}
		public String getCode(){
			return this.name();
		}
		public String getCnName(){
			return this.cnName;
		}
		public static String getCnName(String code){
			for(BUSINESS_CYCLE item:BUSINESS_CYCLE.values()){
				if(item.getCode().equals(code))
				{
					return item.getCnName();
				}
			}
			return code;
		}
		public String toString(){
			return "code:"+this.name()+",cnName:"+this.cnName;
		}
	}
	
	/**订单金额修改申请类型**/
	public static enum ORDER_AMOUNT_MODIFY_STATUS{
		UNVERIFIED("未审核"),
		PASS("已审核"),
		CONFIRM("已确定"),
		CANCEL("取消"),
		FAIL("审核不通过");
		
		private String cnName;
		ORDER_AMOUNT_MODIFY_STATUS(String name){
			this.cnName=name;
		}
		public String getCode(){
			return this.name();
		}
		public String getCnName(){
			return this.cnName;
		}
		public static String getCnName(String code){
			for(ORDER_AMOUNT_MODIFY_STATUS item:ORDER_AMOUNT_MODIFY_STATUS.values()){
				if(item.getCode().equals(code))
				{
					return item.getCnName();
				}
			}
			return code;
		}
		public String toString(){
			return "code:"+this.name()+",cnName:"+this.cnName;
		}
	}
	
	
	public static Constant getInstance() {
		if (instance == null) {
			synchronized (Constant.class) {
				if(instance==null){					
					instance = new Constant();
					//instance.init();
				}
			}
		}
		return instance;
	}
	
	/**
	 * JOB是否运行
	 * @return
	 */
	public boolean isJobRunnable() {
		String jobEnabled = properties.getProperty("job.enabled");
		if (jobEnabled != null) {
			return Boolean.valueOf(jobEnabled);
		} else {
			return true;
		}
	}
	
}


